home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / java / security / Identity.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  4.2 KB  |  206 lines

  1. package java.security;
  2.  
  3. import java.io.Serializable;
  4. import java.util.Arrays;
  5. import java.util.Enumeration;
  6. import java.util.Vector;
  7.  
  8. /** @deprecated */
  9. @Deprecated
  10. public abstract class Identity implements Principal, Serializable {
  11.    private static final long serialVersionUID = 3609922007826600659L;
  12.    private String name;
  13.    private PublicKey publicKey;
  14.    String info;
  15.    IdentityScope scope;
  16.    Vector certificates;
  17.  
  18.    protected Identity() {
  19.       this("restoring...");
  20.    }
  21.  
  22.    public Identity(String var1, IdentityScope var2) throws KeyManagementException {
  23.       this(var1);
  24.       if (var2 != null) {
  25.          var2.addIdentity(this);
  26.       }
  27.  
  28.       this.scope = var2;
  29.    }
  30.  
  31.    public Identity(String var1) {
  32.       this.info = "No further information available.";
  33.       this.name = var1;
  34.    }
  35.  
  36.    public final String getName() {
  37.       return this.name;
  38.    }
  39.  
  40.    public final IdentityScope getScope() {
  41.       return this.scope;
  42.    }
  43.  
  44.    public PublicKey getPublicKey() {
  45.       return this.publicKey;
  46.    }
  47.  
  48.    public void setPublicKey(PublicKey var1) throws KeyManagementException {
  49.       check("setIdentityPublicKey");
  50.       this.publicKey = var1;
  51.       this.certificates = new Vector();
  52.    }
  53.  
  54.    public void setInfo(String var1) {
  55.       check("setIdentityInfo");
  56.       this.info = var1;
  57.    }
  58.  
  59.    public String getInfo() {
  60.       return this.info;
  61.    }
  62.  
  63.    public void addCertificate(Certificate var1) throws KeyManagementException {
  64.       check("addIdentityCertificate");
  65.       if (this.certificates == null) {
  66.          this.certificates = new Vector();
  67.       }
  68.  
  69.       if (this.publicKey != null) {
  70.          if (!this.keyEquals(this.publicKey, var1.getPublicKey())) {
  71.             throw new KeyManagementException("public key different from cert public key");
  72.          }
  73.       } else {
  74.          this.publicKey = var1.getPublicKey();
  75.       }
  76.  
  77.       this.certificates.addElement(var1);
  78.    }
  79.  
  80.    private boolean keyEquals(Key var1, Key var2) {
  81.       String var3 = var1.getFormat();
  82.       String var4 = var2.getFormat();
  83.       if (var3 == null ^ var4 == null) {
  84.          return false;
  85.       } else {
  86.          return var3 != null && var4 != null && !var3.equalsIgnoreCase(var4) ? false : Arrays.equals(var1.getEncoded(), var2.getEncoded());
  87.       }
  88.    }
  89.  
  90.    public void removeCertificate(Certificate var1) throws KeyManagementException {
  91.       check("removeIdentityCertificate");
  92.       if (this.certificates != null) {
  93.          this.certificates.removeElement(var1);
  94.       }
  95.  
  96.    }
  97.  
  98.    public Certificate[] certificates() {
  99.       if (this.certificates == null) {
  100.          return new Certificate[0];
  101.       } else {
  102.          int var1 = this.certificates.size();
  103.          Certificate[] var2 = new Certificate[var1];
  104.          this.certificates.copyInto(var2);
  105.          return var2;
  106.       }
  107.    }
  108.  
  109.    public final boolean equals(Object var1) {
  110.       if (var1 == this) {
  111.          return true;
  112.       } else if (var1 instanceof Identity) {
  113.          Identity var2 = (Identity)var1;
  114.          return this.fullName().equals(var2.fullName()) ? true : this.identityEquals(var2);
  115.       } else {
  116.          return false;
  117.       }
  118.    }
  119.  
  120.    protected boolean identityEquals(Identity var1) {
  121.       if (!this.name.equalsIgnoreCase(var1.name)) {
  122.          return false;
  123.       } else if (this.publicKey == null ^ var1.publicKey == null) {
  124.          return false;
  125.       } else {
  126.          return this.publicKey == null || var1.publicKey == null || this.publicKey.equals(var1.publicKey);
  127.       }
  128.    }
  129.  
  130.    String fullName() {
  131.       String var1 = this.name;
  132.       if (this.scope != null) {
  133.          var1 = var1 + "." + this.scope.getName();
  134.       }
  135.  
  136.       return var1;
  137.    }
  138.  
  139.    public String toString() {
  140.       check("printIdentity");
  141.       String var1 = this.name;
  142.       if (this.scope != null) {
  143.          var1 = var1 + "[" + this.scope.getName() + "]";
  144.       }
  145.  
  146.       return var1;
  147.    }
  148.  
  149.    public String toString(boolean var1) {
  150.       String var2 = this.toString();
  151.       if (var1) {
  152.          var2 = var2 + "\n";
  153.          var2 = var2 + this.printKeys();
  154.          var2 = var2 + "\n" + this.printCertificates();
  155.          if (this.info != null) {
  156.             var2 = var2 + "\n\t" + this.info;
  157.          } else {
  158.             var2 = var2 + "\n\tno additional information available.";
  159.          }
  160.       }
  161.  
  162.       return var2;
  163.    }
  164.  
  165.    String printKeys() {
  166.       String var1 = "";
  167.       if (this.publicKey != null) {
  168.          var1 = "\tpublic key initialized";
  169.       } else {
  170.          var1 = "\tno public key";
  171.       }
  172.  
  173.       return var1;
  174.    }
  175.  
  176.    String printCertificates() {
  177.       String var1 = "";
  178.       if (this.certificates == null) {
  179.          return "\tno certificates";
  180.       } else {
  181.          var1 = var1 + "\tcertificates: \n";
  182.          Enumeration var2 = this.certificates.elements();
  183.  
  184.          Certificate var4;
  185.          for(int var3 = 1; var2.hasMoreElements(); var1 = var1 + "\t\t\tfrom : " + var4.getGuarantor() + "\n") {
  186.             var4 = (Certificate)var2.nextElement();
  187.             var1 = var1 + "\tcertificate " + var3++ + "\tfor  : " + var4.getPrincipal() + "\n";
  188.          }
  189.  
  190.          return var1;
  191.       }
  192.    }
  193.  
  194.    public int hashCode() {
  195.       return this.name.hashCode();
  196.    }
  197.  
  198.    private static void check(String var0) {
  199.       SecurityManager var1 = System.getSecurityManager();
  200.       if (var1 != null) {
  201.          var1.checkSecurityAccess(var0);
  202.       }
  203.  
  204.    }
  205. }
  206.